<?php

/**
 * Project: CrazyPoems
 * Author: Alexandru
 * Date: 20/10/2008
 * File: member.php
 */

// Load default settings.
require('inc/config.php');
require('inc/functions.misc.php');
require('inc/functions.index.php');
require('inc/functions.member.php');

// Get member info.
$username = $_GET['name'];

// If no user is specified own profile is shown.
if (strlen($username) == 0) {
	$username = $cookie->username;
}

$q = mysql_query("SELECT * FROM " . TABLE_USERS . " WHERE username = '$username'") or die(mysql_error());
$r = mysql_fetch_assoc($q);
if ($r) {
	$smarty->assign('fullname', $r['fullname']);
	$smarty->assign('email', $r['email']);
    $smarty->assign('memberSince', parseDate($r['member_since']));
	$smarty->assign('lastLogin', parseDate($r['last_login']));
	if ($r['photo_approved'] == "yes") {
		$smarty->assign('photo', Hop_getUserPhoto($r['photo']));
	}
	$smarty->assign('pageTitle', 'Detalii membru: '.$username);
	$smarty->assign('breadcrumbs', '<a href="'.BASE_URL.'">'.l('Inicio').'</a> &raquo; <a href="'.BASE_URL.'members.php">'.l(Miembros).'</a> &raquo; '.$username);
    $smarty->assign('userPoems', Hop_getUserPoems($username));
    $smarty->assign('userPoemsCount', Hop_countUserPoems($username));
} else {
	$smarty->assign('pageTitle', 'Membru necunoscut: '.$username);
	$smarty->assign('unknownMember', 'yes');
}
$smarty->assign('username', $username);

// Go!
$smarty->display('member.tpl');

// End page.
require('inc/end.php');
?>
